﻿using ZYCommon;
using System;
using System.Drawing;

namespace TextEditor
{
    

    public class A_FormatAll : A_Action
    {
        public override string ActionName()
        {
            return "formatall";
        }

        public override A_Action Clone()
        {
            A_FormatAll all = new A_FormatAll();
            all.BaseCloneFrom(this);
            return all;
        }

        public override bool Execute()
        {
            base.myOwnerDocument.FormatAll = base.Param1 == "1";
            if (StringCommon.HasContent(base.Param2))
            {
                float size = base.myOwnerDocument.View.DefaultFont.Size;
                if (StringCommon.IsNumberic(base.Param3))
                {
                    size = Convert.ToSingle(base.Param3);
                }
                base.myOwnerDocument.View.DefaultFont = new Font(base.Param2, size);
            }
            return true;
        }

        public override bool isEnable()
        {
            return base.myOwnerDocument.CanModify();
        }
    }
}

